import com.beans.User;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.core.io.ClassPathResource;

/**
 * \* Created with IntelliJ IDEA.
 * \* User: Administrator
 * \* Date: 2022/7/3
 * \* Time: 14:04
 * \* To change this template use File | Settings | File Templates.
 * \* Description:
 * \
 */
public class App {
    public static void main(String[] args) {
//        //1.得到spring上下文对象
          ApplicationContext context = new ClassPathXmlApplicationContext("spring-config.xml");
//
//        //2.根据上下文提供的方法获取到bean
//          User user = (User) context.getBean("user");
//
        User user = context.getBean(User.class);
//        //3.使用bean
          user.sayHi("张三");

//        //1.得到bean工厂
//        BeanFactory factory = new XmlBeanFactory(new ClassPathResource("spring-config.xml"));
//
//        //2.获取bean
//        User user =(User) factory.getBean("user");
//
//        //3.使用bean
//        user.sayHi("李四");

    }
}
